package transfer;

import java.util.Date;
import java.util.HashMap;

/**
 * This class represents order from database. This is used for transferring.
 *
 * @author Vadym Gula
 * @author Oleh Tarapata
 */
public class Order {

    private Integer idOrder;
    private Warehouse warehouse;
    private OrderState orderState;
    private User customer;
    private Date creationDate;
    private Date deliveredDate;
    private Address address;
    private Double totalCost;
    private String email;
    private Boolean isSubscribed;
    private HashMap commodities;
    private User courier;
    private User warehouseEmployee;
    private Double costCommodities;
    private Double costDelivery;
    private Double distance;

    public Order() {
    }

    public Order(Integer idOrder, Warehouse warehouse, OrderState orderState, User user, Date creationDate, Date deliveredDate, Address address, Double totalCost, String email, Boolean isSubscribed, HashMap commodities) {
        this.idOrder = idOrder;
        this.warehouse = warehouse;
        this.orderState = orderState;
        this.customer = user;
        this.creationDate = creationDate;
        this.deliveredDate = deliveredDate;
        this.address = address;
        this.totalCost = totalCost;
        this.email = email;
        this.isSubscribed = isSubscribed;
        this.commodities = commodities;
    }

    public Integer getIdOrder() {
        return idOrder;
    }

    public void setIdOrder(Integer idOrder) {
        this.idOrder = idOrder;
    }

    public Warehouse getWarehouse() {
        return warehouse;
    }

    public void setWarehouse(Warehouse warehouse) {
        this.warehouse = warehouse;
    }

    public OrderState getOrderState() {
        return orderState;
    }

    public void setOrderState(OrderState orderState) {
        this.orderState = orderState;
    }

    public User getCustomer() {
        return customer;
    }

    public void setCustomer(User user) {
        this.customer = user;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public Date getDeliveredDate() {
        return deliveredDate;
    }

    public void setDeliveredDate(Date deliveredDate) {
        this.deliveredDate = deliveredDate;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public Double getTotalCost() {
        return totalCost;
    }

    public void setTotalCost(Double totalCost) {
        this.totalCost = totalCost;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getIsSubscribed() {
        return isSubscribed;
    }

    public void setIsSubscribed(Boolean isSubscribed) {
        this.isSubscribed = isSubscribed;
    }

    public HashMap getCommodities() {
        return commodities;
    }

    public void setCommodities(HashMap commodities) {
        this.commodities = commodities;
    }

    public String toString() {
        String result = "Order:\n";
        result += "idOrder = " + idOrder + "\n";
        result += "orderState = " + orderState.getNameOrderState() + "\n";
        result += "totalCost = " + totalCost + "\n";
        result += "commodityCount = " + commodities.size() + "\n";
        return result;
    }

    public User getCourier() {
        return courier;
    }

    public void setCourier(User courier) {
        this.courier = courier;
    }

    public User getWarehouseEmployee() {
        return warehouseEmployee;
    }

    public void setWarehouseEmployee(User warehouseEmployee) {
        this.warehouseEmployee = warehouseEmployee;
    }

    public Double getCostCommodities() {
        return costCommodities;
    }

    public void setCostCommodities(Double costCommodities) {
        this.costCommodities = costCommodities;
    }

    public Double getCostDelivery() {
        return costDelivery;
    }

    public void setCostDelivery(Double costDelivery) {
        this.costDelivery = costDelivery;
    }

    public Double getDistance() {
        return distance;
    }

    public void setDistance(Double distance) {
        this.distance = distance;
    }

    public int hashCode() {
        return idOrder.intValue();
    }

    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Order other = (Order) obj;
        return idOrder.equals(other.idOrder);
    }
}
